Method 4 – Creating Customized License Generator Using API Functions

Alternatively, you can use the license code generation API for generating license codes. This involves a typical sequence of operations described below:

>Allocate an integer handle and a data structure of type codeT. The handle is used with all other license generation functions, and must be initialized before any of those functions can be called. The codeT data structure is used to pass arguments back and forth between the program and the different library functions.

>Call VLScgInitialize to initialize the handle. This will ensure that the number of handles has not exceeded the limit, allocate space for internal data structures, and initialize the error list and error count.

>Call VLScgReset to initialize default values into the codeT data structure. This must be done before setting the values of any of the fields in the data structure.

>Obtain input from the user that is to be used to define the license code. The order of input is important since some values will depend on others. The order of input refers to the Allow and Set functions of code struct. We suggest you use the Allow function first to check the differential integrity of the field value before using the Set function. Call the appropriate VLScgAllowXXX function for each input to ensure that its value can be properly included into the license code. If the input can be accepted, call the corresponding VLScgSetXXX function. This will lock the codeT data structure, install the value in the designated field, and then unlock the structure. If the set function causes an error, call VLScgPrintError function to copy the error structure to a specified file.

>After all inputs have been received, call VLScgGenerateLicense to create the license string.

>Call VLScgCleanup to release the handle.

See Platforms, Libraries, and Compilers to check for the availability of RMS license generation libraries on various platforms. Also, refer to “Chapter - License Code Generation API” of the Sentinel RMS API Reference Guide for details about the license generation API functions.

NOTE    On Windows, RMS provides the license generation COM component that can be registered and can be used by a COM application. Contact Technical Support for requesting the COM component for license generation.

#define VLS_CGENXMPL_FEATURE_NAME "CGENXMPL"
int main ()
{
  VLScg_HANDLE iHandle;
  codeT licCode;
  VLScgInitialize(&iHandle)
  VLScgReset(iHandle,&licCode)
  VLScgAllowFeatureName(iHandle, &licCode)
  VLScgSetFeatureName(iHandle, &licCode,VLS_CGENXMPL_FEATURE_NAME)
  ............
  ............
  VLScgGenerateLicense(iHandle, &licCode, &licStr)
  VLScgCleanup(&iHandle);
}